var ReduceAmountDlg = {
    width: '650px',
    height: '650px',
    cache: "",
    orderItemId: "",       //订单明细ID
    id: "newCourseTable", //表格id
    me: "",
    countIndex: ""
};

/**
 * 初始化新增弹出框
 */
ReduceAmountDlg.init = function () {
    this.cache = $("#reduceAmountDlg").html();
    $("#reduceAmountDlg").html('');
};

/**
 * 关闭此对话框
 */
ReduceAmountDlg.close = function () {
    layer.close(this.currentLayerIndex);
};

/**
 * 调整课程金额表单初始化
 */
ReduceAmountDlg.reducePromotionAmount = function (orderNum,orderItemId,courseName,courseAmount) {
    $("#val_orderNum").val(orderNum);
    $("#val_orderItemId").val(orderItemId);
    $("#courseName").val(courseName);
    $("#courseAmount").val(courseAmount);
    $("#reduceAmount").val(0);
};

/**
 * 提交修改请求
 */
ReduceAmountDlg.reducePromotionAmountSubmit = function (index) {
    //发送调整请求
    var option = {
        orderItemId: $("#val_orderItemId").val(),
        reduceAmount: $("#reduceAmount").val(),
        orderNum: $("#val_orderNum").val()
    };
    var ajax = new $ax(Feng.ctxPath + "/order/updateNoPayOrderItemAmount", function (data) {
        if (data.success) {
            Feng.success("修改成功!");
            _promotionAmount="_promotionAmount"+index;
            _courseAmount="_courseAmount"+index;
            _this=$('#courseTableBody #'+_promotionAmount);
            _this2=$('#courseTableBody #'+_courseAmount);
            _reduceAmount=$("#reduceAmount").val();
            var a=_this.html();
            _this.html(numeral(Number(a)+Number(_reduceAmount)).format('0,0.00'));
            _this2.html(numeral(Number(_this2.html())-Number(_reduceAmount)).format('0,0.00'));
            $('#orderAmount').html(numeral(Number($('#orderAmount').html())-Number(_reduceAmount)).format('0,0.00'));
            $('#_aucture').html(numeral(Number($('#_aucture').html())-Number(_reduceAmount)).format('0,0.00'));
            $('#_orderture').html(numeral(Number($('#_orderture').html())-Number(_reduceAmount)).format('0,0.00'));
            // ReduceAmountDlg.close();
            // OrderInfoDlg.close();
            // OrderTable.me.destroy();
        } else if (data.code === 2) {
            Feng.error(data.msg);
        } else {
            Feng.error("修改失败!");
        }
    }, function (data) {
        Feng.error("修改失败!");
    });
    ajax.setData(option);
    ajax.start();
};
